<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增项目迭代任务成员')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-projectEmp-add">
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label is-required">项目id：</label>
                <div class="col-sm-8">
                    <input name="projectId" th:value="${projectId}" class="form-control" type="number" >
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label is-required">迭代id：</label>
                <div class="col-sm-8">
                    <input name="projectPlanId" th:value="${projectPlanId}" class="form-control" type="number" >
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label is-required">任务id：</label>
                <div class="col-sm-8">
                    <input name="projectPlanTaskId" th:value="${projectPlanTaskId}" class="form-control" type="number" >
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">成员id：</label>
                <div class="col-sm-8">
                    <div class='input-group'>
                        <input class='form-control' type='hidden' name='empIds' id='empIds' required>
                        <input class='form-control' type='hidden' name='userId' id='userId' required>
                        <textarea class='form-control' rows="3" type="text" name='empName' id='empName' readonly="readonly" required></textarea>
                        <span class='input-group-addon input-sm' onclick='selectEmpTree("", this)'>
                            <i class='fa fa-search'>选择</i>
                        </span>
                    </div>
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">类型：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_project_type')}">
                        <input type="radio" th:id="${'type_' + dict.dictCode}" name="type" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
                        <label th:for="${'type_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "project/projectEmp"
        $("#form-projectEmp-add").validate({
            focusCleanup: true
        });

        $("input[name=type]").val( [[${type}]]);

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-projectEmp-add').serialize());
            }
        }

        // 选择字典处理函数
        function selectEmpTree(columnId, obj) {
            // var dictType = $.common.nullToStr($(obj).parent().find("input").val());
            var url = ctx + "system/user/selectUserTreeCheckbox?msg=最多添加40位成员&count=40&projectId="
                    +$("input[name=projectId]").val() + "&type="+$("input[name=type]").val();
            var options = {
                title: '选择成员',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index){
            // debugger
            var body = layer.getChildFrame('body', index);
            var userId = body.find('#userId').val();
            var empName = body.find('#empName').val();
            var userNameShow = body.find('#userNameShow').val();
            layer.close(index);
            $("#empIds").val(userId);
            $("#userId").val(userId);
            $("#empName").val(empName);
        }


    </script>
</body>
</html>